package one.stand.service.impl;

import com.alibaba.fastjson.JSON;
import one.stand.OneCrmServiceApplicationTests;
import one.stand.request.CompanyCustomerLableRequest;
import one.stand.request.GoodSpecRequest;
import one.stand.request.GoodsRequest;
import one.stand.service.CompanyCustomerLableService;
import one.stand.service.GoodsService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: QIK
 * @CreateDate: 2019/4/21 16:24
 */
@TestConfiguration
public class Lable extends OneCrmServiceApplicationTests {

    @Autowired
    CompanyCustomerLableService companyCustomerLableService;

    @Autowired
    GoodsService goodsService;

    @Test
    public void addGoodsInfo(){
        GoodsRequest request = new GoodsRequest();
        request.setCId(67L);
        request.setRoleId(67);
        request.setGoodsId(122);
        request.setGoodstypeId(92);
        request.setGoodsName("test1_1");
        request.setGoodsDetails("test1_1");
        request.setIspayment(1);
        request.setSpecIds("516,517,518,519,520,521");
        request.setGoodPhoto("aaa,bbb");
        System.err.println(JSON.toJSONString(request));
        goodsService.addGoodsInfo(request);
    }

    @Test
    public void addGoodsInfoList(){
        GoodsRequest request = new GoodsRequest();
        request.setCId(67L);
        request.setRoleId(67);
        request.setGoodstypeId(92);
        request.setGoodsName("test1");
        request.setGoodsDetails("test1");
        request.setIspayment(1);
        request.setGoodsId(122);
        GoodSpecRequest request1 = new GoodSpecRequest();
        request1.setSpecName("种类一1");
        request1.setSpecId(516);
        GoodSpecRequest request2 = new GoodSpecRequest();
        request2.setPrice(100);
        request2.setSpecNum(99);
        request2.setSpecAttribute("熟悉三1");
        request2.setSpecId(517);
        GoodSpecRequest request3 = new GoodSpecRequest();
        request3.setPrice(100);
        request3.setSpecNum(99);
        request3.setSpecAttribute("熟悉四1");
        request3.setSpecId(518);
        List<GoodSpecRequest> list = new ArrayList<>();
        list.add(request2);
        list.add(request3);
        request1.setList(list);
        GoodSpecRequest request4 = new GoodSpecRequest();
        request4.setSpecName("种类二1");
        request4.setSpecId(519);
        GoodSpecRequest request5 = new GoodSpecRequest();
        request5.setPrice(100);
        request5.setSpecNum(99);
        request5.setSpecAttribute("熟悉一1");
        request5.setSpecId(520);
        GoodSpecRequest request6 = new GoodSpecRequest();
        request6.setPrice(100);
        request6.setSpecNum(99);
        request6.setSpecAttribute("熟悉二1");
        request6.setSpecId(521);
        List<GoodSpecRequest> list1 = new ArrayList<>();
        list1.add(request5);
        list1.add(request6);
        request4.setList(list1);
        List<GoodSpecRequest> list2 = new ArrayList<>();
        list2.add(request1);
        list2.add(request4);
        request.setGoodSpecRequestList(list2);
        System.err.println(JSON.toJSONString(request));
        //goodsService.addGoodsInfoList(request);
    }

    @Test
    public void del(){
        System.err.println(companyCustomerLableService.delLable(new CompanyCustomerLableRequest(){{
            setLableId(7);
        }}));
    }
}
